home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH13 / 13-3-1P.CLS < prev    next >
Encoding:
Visual Basic class definition  |  1998-11-02  |  2.0 KB  |  75 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CPlane"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Private m_imgPlane As Image 'image control associated with plane
  15.  
  16. Property Let imagePlane(newPlane As Image)
  17.   Set m_imgPlane = newPlane
  18. End Property
  19.  
  20. Public Function Present() As Boolean
  21.   'Determine if the plane is visible
  22.   'Will be needed by the bomb object.
  23.   If m_imgPlane.Visible Then
  24.       Present = True
  25.     Else
  26.       Present = False
  27.   End If
  28. End Function
  29.  
  30. Public Function X() As Integer
  31.   X = m_imgPlane.Left
  32. End Function
  33.  
  34. Public Function Y() As Integer
  35.   Y = m_imgPlane.Top
  36. End Function
  37.  
  38. Public Function W() As Integer
  39.  W = m_imgPlane.Width
  40. End Function
  41.  
  42. Public Function H() As Integer
  43.   H = m_imgPlane.Height
  44. End Function
  45.  
  46. Public Sub Fly(ByVal dir As String, ByVal Height As Integer, ByVal Width As Integer)
  47.   m_imgPlane.Visible = True
  48.   'Meanings of variables
  49.   'dir     Direction of airplane (Right, Up, or Down)
  50.   'Height  Height of form
  51.   'Width   Width of form
  52.   If dir = "Up" Then
  53.       'Prevent airplane from rising off the screen.
  54.       If (m_imgPlane.Top - 500) >= 0 Then
  55.          m_imgPlane.Top = m_imgPlane.Top - 500
  56.        End If
  57.     ElseIf dir = "Down" Then
  58.       'Prevent airplane from falling off the screen.
  59.       If (m_imgPlane.Top + m_imgPlane.Height + 500) <= Height Then
  60.           m_imgPlane.Top = m_imgPlane.Top + 500
  61.       End If
  62.     ElseIf dir = "Right" Then
  63.       'Prevent airplane from moving off the screen.
  64.       If (m_imgPlane.Left + m_imgPlane.Width + 500) <= Width Then
  65.           m_imgPlane.Left = m_imgPlane.Left + 500
  66.       End If
  67.   End If
  68. End Sub
  69. Public Sub Destroy()
  70.   m_imgPlane.Visible = False
  71. End Sub
  72. Private Sub Class_Terminate()
  73.   Set m_imgPlane = Nothing
  74. End Sub
  75.